package com.jrtc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jrtc.base.entity.bo.Doctorservicedoctor;
import com.jrtc.dao.DoctorservicedoctorDao;
import com.jrtc.service.DoctorservicedoctorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 医生医事服务关联表(Doctorservicedoctor)表服务实现类
 *
 * @author makejava
 * @since 2022-03-21 17:34:12
 */
@Service("doctorservicedoctorService")
public class DoctorservicedoctorServiceImpl implements DoctorservicedoctorService
{
    @Resource
    private DoctorservicedoctorDao doctorservicedoctorDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Doctorservicedoctor queryById(Integer id) {
        return this.doctorservicedoctorDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Doctorservicedoctor> queryAllByLimit(int offset, int limit) {
        return this.doctorservicedoctorDao.queryAllByLimit(offset, limit);
    }

    @Override
    public IPage<Doctorservicedoctor> queryDoctorservicedoctorList(Doctorservicedoctor doctorservicedoctor)
    {
        com.baomidou.mybatisplus.extension.plugins.pagination.Page<Doctorservicedoctor> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(doctorservicedoctor.getPageNo(), doctorservicedoctor.getPageSize());
        IPage<Doctorservicedoctor> doctorservicedoctorPage = this.doctorservicedoctorDao.queryDoctorservicedoctorList(page, doctorservicedoctor);
        return doctorservicedoctorPage;
    }
    /**
     * 新增数据
     *
     * @param doctorservicedoctor 实例对象
     * @return 实例对象
     */
    @Override
    public Doctorservicedoctor insert(Doctorservicedoctor doctorservicedoctor) {
        this.doctorservicedoctorDao.insert(doctorservicedoctor);
        return doctorservicedoctor;
    }

    /**
     * 修改数据
     *
     * @param doctorservicedoctor 实例对象
     * @return 实例对象
     */
    @Override
    public Doctorservicedoctor update(Doctorservicedoctor doctorservicedoctor) {
        this.doctorservicedoctorDao.update(doctorservicedoctor);
        return this.queryById(doctorservicedoctor.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.doctorservicedoctorDao.deleteById(id) > 0;
    }
}